import request from '@/utils/request'

// 获取小说详情
export const getNovelDetail = (id) => {
    return request.get('/web/novelDetail/getNovelReadingDetail/' + id)
}

// 获取章节内容
export const getNovelChapterContent = (id) => {
    return request.get('/web/novelReading/getChapterContent/' + id)
}

// 获取章节列表
export const getNovelChapterList = (novelId, chapterId) => {
    return request.get('/web/novelReading/getChapterList?novelId=' + novelId + '&chapterId=' + chapterId)
}
// 添加到书架
export const addToBookShelf = (userId, novelId, chapterId) => {
    return request.post('/web/novelDetail/addNovel', {
        userId: userId,
        novelId: novelId,
        chapterId: chapterId
    })
}

// 移出书架
export const removeFromBookShelf = (userId, novelId) => {
    const param = { novelId: novelId, userId: userId };
    return request.delete('/web/novelDetail/removeNovel', { data: param })
}

// 获取主评论
export const getMainComments = (novelId, page, size) => {
    return request.get('/web/novelDetail/getNovelMainComments?novelId=' + novelId + '&page=' + page + '&size=' + size)
}

// 获取子评论
export const getChildComments = (commentId, page, size) => {
    return request.get('/web/novelDetail/getNovelChildComments?commentId=' + commentId + '&page=' + page + '&size=' + size)
}

// 发布评论
export const publishComment = (novelId, content, toUserId,commentId) => {
    return request.post('/web/novelDetail/saveComments', {
        content: content,
        novelId: novelId,
        toUserId: toUserId,
        commentId: commentId
    })
}

// 点赞评论
export const addGood = (commentId) => {
    return request.post('/web/novelDetail/addGood', {
        commentId: commentId
    })
}

// 取消点赞评论
export const cancelGood = (commentId) => {
    return request.post('/web/novelDetail/cancelGood', {
        commentId: commentId
    })
}